package assignment.ton.gui.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import assignment.ton.gui.CodeEditorFrame;
import assignment.ton.gui.MainFrame;
/**
 * The action listener for the code editor
 * @author Shaun Close (shc10)
 */
public class CodeEditorFrameActionListener implements ActionListener{
	private CodeEditorFrame codeEditorFrame;
	private MainFrame mainFrame;
	public CodeEditorFrameActionListener(CodeEditorFrame codeEditorFrame, MainFrame mF){
		this.codeEditorFrame = codeEditorFrame;
		mainFrame = mF;
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		String actionCommand = e.getActionCommand();
		if(actionCommand.equals("Save")){
			codeEditorFrame.save();
		}else if(actionCommand.equals("Close")){
			cancel();
		}
		mainFrame.getDrawPanel().repaint();
	}
	public void cancel(){
		codeEditorFrame.cancel();
	}

}
